#ifndef FTPCLIENTPANEL_H
#define FTPCLIENTPANEL_H

#include <QWidget>
#include <QFileSystemModel>
#include <QTcpSocket>
#include <QVector>
#include <QTreeWidget>
#include <QInputDialog>
#include <QUrlInfo>

#include "ftp.h"
#include "fileinfo.h"
namespace Ui {
class FtpClientPanel;
}

class FtpClientPanel : public QWidget
{
    Q_OBJECT

public:
    explicit FtpClientPanel(QWidget *parent = 0);
    ~FtpClientPanel();

    QString _FromSpecialEncoding(const QString &InputStr);
    QString _ToSpecialEncoding(const QString &InputStr);

private slots:
    void on_btn_UP_clicked();
    void on_btn_DN_clicked();
    void on_connectButton_clicked();

private slots:
    void connected();
    void disconnected();
    void response(QString);
    void message(QString);

    void on_remoteFiles_itemDoubleClicked(QTreeWidgetItem *item, int column);
    void on_localFiles_clicked(const QModelIndex &index);
    void populateList(QVector<FileInfo>);

    void on_remoteFiles_itemClicked(QTreeWidgetItem *item, int column);
    void populateDownloadBar(qint64 bytes);
    void populateUploadBar(qint64 bytes);
    void addToServerList(const QUrlInfo &urlInfo);

    void on_downloadButton_clicked();

    void on_uploadButton_clicked();

    void on_btn_clear_clicked();

private:
    Ui::FtpClientPanel *ui;
    Ftp *ftp;
    bool disconnect;
    QFileSystemModel *fileModel;
    void getRemoteFiles(QString path = "/");

    void SaveFtpConfig();
    void LoadFtpConfig();

    int bytesDownloaded;
    int bytesUploaded;
    quint64 totalBytes;
};

#endif // FTPCLIENTPANEL_H
